﻿/// <reference path="jquery-1.7.1.js" />
/// <reference path="jquery.form.js" />
/// <reference path="~/Scripts/layer/layer.js" />

var editor;
$(document).ready(function () {
    submit();
    $(function () {
        $(":input[name='Email']").blur(function () {
            var email = $(this).val();
            var reg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
            if (email != "" && !reg.test(email)) {
                $(this).focus();
                layer.msg('请输入正确的email地址!');
            }
        });
    });
});
//Tab控制函数
function submit() {
<<<<<<< HEAD
    
=======
>>>>>>> 0bd1b049090dc0a26e74ed32aa07cf807c1e3755
    // prepare Options Object 
    var options = {
        // other available options:             
        url: '/FeedBack/Save/?' + new Date().getMilliseconds(),  // override for form's 'action' attribute 
        //target:        '#output2',   // target element(s) to be updated with server response 
        // beforeSubmit: showRequest,  // pre-submit callback 
        type: 'post',    // 'get' or 'post', override for form's 'method' attribute 
        data: { mid: $('#mid').val(), CategoryId: $('#cid').val(), id: $('#id').val() },
        dataType: 'json',        // 'xml', 'script', or 'json' (expected server response type) 
        //clearForm: true        // clear all form fields after successful submit 
        //resetForm: true        // reset the form after successful submit 

        // $.ajax options can be used here too, for example: 
        //timeout:   3000 
        success: function () {

            //art.dialog({
            //    title: '消息提示',
            //    content: '保存成功'
            //});
            layer.msg('保存成功!');
            $("input[type='text']").val("");
            $("textarea").val("");
        }
    };


    // bind to the form's submit event 
    $('#frmFeedBack').submit(function () {
        var num = 0;
        var str = "";
        $("input[type$='text']").each(function (n) {
            var notNull = $(this).attr("notNull");
            if ($(this).val() == "" && notNull != undefined) {
                num++;
                str += "【" + notNull + "】不能为空！\r\n";
            }
        });
        if (num > 0) {
            layer.msg(str);
            return false;
        }

        // inside event callbacks 'this' is the DOM element so we first 
        // wrap it in a jQuery object and then invoke ajaxSubmit  
        
        $(this).ajaxSubmit(options);


        // !!! Important !!! 
        // always return false to prevent standard browser submit and page navigation 
        return false;
    });
}


